package com.demo.listener;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;

/**
 * @author WuLiangHang
 */
@WebListener
public class MyListener implements ServletContextAttributeListener, HttpSessionAttributeListener, ServletRequestAttributeListener {
    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println("向ServletContext中添加属性:"+event.getName()+" = " +event.getValue());
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println("向ServletContext中移除属性:"+event.getName()+" = " +event.getValue());

    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println("向ServletContext中修改属性:"+event.getName()+" = " +event.getValue());

    }

    @Override
    public void attributeAdded(ServletRequestAttributeEvent srae) {
        System.out.println("向ServletRequest中添加属性:"+srae.getName()+" = " +srae.getValue());
    }

    @Override
    public void attributeRemoved(ServletRequestAttributeEvent srae) {
        System.out.println("向ServletRequest中移除属性:"+srae.getName()+" = " +srae.getValue());
    }

    @Override
    public void attributeReplaced(ServletRequestAttributeEvent srae) {
        System.out.println("向ServletRequest中修改属性:"+srae.getName()+" = " +srae.getValue());
    }

    @Override
    public void attributeAdded(HttpSessionBindingEvent event) {
        System.out.println("向ServletContext中添加属性:"+event.getName()+" = " +event.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent event) {
        System.out.println("向ServletContext中移除属性:"+event.getName()+" = " +event.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent event) {
        System.out.println("向ServletContext中修改属性:"+event.getName()+" = " +event.getValue());
    }
}
